{% extends 'base.html' %}

{% block subtitle %}
  {% trans %} Announcements {% endtrans %}
{% endblock subtitle %}

{% block top_content %}
{% endblock %}

{% block main_content %}
<div class="gcb-main">
  <div class="gcb-article tab-content">
    <div class="gcb-aside">
      {% if announcements %}
        {% if announcements.add_action %}
          <form id='gcb-add-announcement' action='{{ announcements.add_action }}' method='POST'>
            <input type="hidden" name="xsrf_token" value="{{ announcements.add_xsrf_token|escape }}">
            <button class="gcb-button gcb-button-action" type="submit">{% trans %} Add New {% endtrans %}</button>
          </form>
          <div style='clear: both; padding-top: 2px;' />
        {% endif %}
        {% if not announcements.children %}
          <p>{% trans %} No announcements yet. {% endtrans %}</p>
        {% endif %}
        {% for item in announcements.children %}
          <hr>
          {% if item.delete_action %}
          <form id='gcb-delete-announcement-{{ loop.index0 }}' action='{{ item.delete_action }}' method='POST'>
            <input type="hidden" name="xsrf_token" value="{{ item.delete_xsrf_token|escape }}">
            <button class="gcb-button gcb-button-action" type="submit"
              onclick='return confirm("Delete this item?");'>
              {% trans %} Delete {% endtrans %}
            </button>
          </form>
          {% endif %}
          {% if item.edit_action %}
            <a role="button" href="{{ item.edit_action }}" class="gcb-button gcb-button-action">
              {% trans %} Edit {% endtrans %}
            </a>
          {% endif %}
          <h2>
            <a name='{{ item.key }}'></a>
            {{ item.title }}{% if item.is_draft %}{% trans %} (Draft) {% endtrans %}{% endif %}
          </h2>
          <p>{{ item.date }}</p>
          <p "margin: 20px 0px;">
          {{ item.html | safe }}
        {% endfor %}
      {% endif %}
    </div>
  </div>
</div>
{% endblock %}
